##作业1
# 猜数字
# • 在程序内随机生成一个数字，让用户猜
# • 检查用户输入的是否为数字
# • 键盘接收用户输入，猜对或猜错都给出提示（大/小）
# • 最多能猜3次
# • 给出用户最终猜的结果，及花了几次来猜

# # 程序如下：

# import random
#
# secret = random.randint(1,10)
# count = 0
# username = input("Please enter your name：")
# print(f"Hi，{username},I am chaochao,I have a important secret,It is a number from 1 to 10,\
# I will give you three times to guess.if you guess right,I will give you some prize,\
# however if you guess wrong,you must sing a song")
# print("The number from 1 to 50，you have three times to guess,Come on！")
# while count < 3:
#     num = input("you have {0} times to guess,please enter your guess：".format(3 - count))
#     if num.isdigit():
#         num = int(num)
#         if num == secret:
#             print("Congratulations,your number is right,your prize is a big hug!")
#             break
#         if num > secret:
#             print("Your number is a little high.")
#         if num < secret:
#             print("Your number is a little low.")
#         count = count + 1
#     else:
#         print("Sorry,what you entered is not an integer.")
#     if count == 3:
#         print(f"I gave you three chances, but you didn't get it right，and the secret is {secret}.")
# print(f"You guessed {count} times,and the secret is {secret}")
# exit()

# #作业2
# 计算复利：想知道如果把10000块钱存入银行，什么时候能变成20000吗？（年利率为5%）
# 利息 = 本金*利率*时间
# 键盘要存入的金额及目标金额
# 输出每年的”本金+利息“
# 给出需要多少年，”本金+利息“ >=目标金额
# # 程序如下：

# principal = float(input("Please enter your principal:"))
# target_amount = float(input("Please enter your target amount:"))
# annual_rate = 0.05
# interest = 0
# year = 0
# count = float(principal)
# while count < float(target_amount):
#     year += 1
#     interest = principal*annual_rate*year
#     count = principal + interest
#     print(f"in the {year} year,your amount are {count}")
# print(f"Your principal has reached {count}, which took {year} years")

# #作业3
# 空气质量查询工具
# • 键盘接收pm2.5的值
# • 根据右表，计算出今天的空气质量
# • 循环输入，'Q'退出

# # 程序如下：

# while True:
#     pm = input("Please enter the pm2.5:")
#     if pm == 'Q':
#         print("You have exited this system.")
#         break
#     else:
#         if float(pm)<0:
#             print("Your input is wrong.")
#         elif float(pm)>=0 and float(pm)<=50:
#             print("The air quality status is:优。You could enter Q to exit the system")
#         elif float(pm)>50 and float(pm) <= 100:
#             print("The air quality status is:良。You could enter Q to exit the system")
#         elif float(pm)>100 and float(pm)<=150:
#             print("The air quality status is:轻度污染。You could enter Q to exit the system")
#         elif float(pm)>150 and float(pm)<=200:
#             print("The air quality status is:中度污染。You could enter Q to exit the system")
#         elif float(pm)>200 and float(pm)<=300:
#             print("The air quality status is:重度污染。You could enter Q to exit the system")
#         elif float(pm)>300:
#             print("The air quality status is:严重污染。You could enter Q to exit the system")
#         else:
#             print("Press Q to launch the system.")

# 作业4：
#  猜大还是小？茶颜等你抢！
#  游戏规则如下：现随机生成3个1~6的色子，三个色子和在3~10 => 小，11~18=>大，您可以在键盘输入猜”大”或”小“，猜一轮，出一轮结果。
#  原始金豆为1000，金豆达1600可获得超超赠送的茶颜悦色一杯！金豆低于500，游戏自动结束！游戏途中用户可输入exit退出游戏。
#  游戏结束后，系统将统计您玩的次数，胜率，已经累计金豆。心动不如行动，下个欧皇就是你！
#  注：玩一把需缴纳1元入场券。

# # 程序如下：

# import random
#
# username = input("请缴纳1元入场券并请输入您的用户名：")
# num = 0
# guess = 0
# i = 0
# a = 0
# b = 0
# rate = 0
# golden_bean = 1000
# try_exit = 0
# while True:
#     if golden_bean<400:
#         print("Your golden bean is less than 400, the game is over.")
#         break
#     elif 500<=golden_bean<1600:
#         num1 = random.randint(1, 6)
#         num2 = random.randint(1, 6)
#         num3 = random.randint(1, 6)
#         num = num1+num2+num3
#         guess = input(f"现有三个色子，三个色子和在3~10则答案为小，11~18则为大，请问{username}您猜大还是猜小：")
#         if 3<=int(num)<=10 and guess == '小' or int(num)>=11 and guess == '大':
#             i += 1
#             a += 1
#             golden_bean += 100
#             rate = float(a/i)
#             print(f"恭喜您猜对了！三个色子分别为{num1},{num2},{num3},合为{guess}。")
#             print(f"您共计完了{i}局，胜率为{rate*100}%,现有积分{golden_bean}分。")
#             if golden_bean == 1600:
#                 print(f"恭喜玩家{username}您的积分已达1600，打通此关，获得超超赠送的茶颜悦色一杯，祝贺您！")
#                 break
#             else:
#                 try_exit = input("若积分达到1600将有惊喜茶颜悦色大礼包，can you try?如需推出请输入exit并按enter键，直接按enter键则继续，您的选择是：")
#                 if try_exit == 'exit':
#                     print(f"游戏已结束，超超期待与{username}您的下一次相遇！")
#                     break
#                 else:
#                     print("游戏继续！惊喜大奖等你来领取！！！")
#         else:
#             i += 1
#             rate = float(a/i)
#             golden_bean -= 100
#             print(f"很遗憾！三个色子分别为{num1},{num2},{num3},您猜错了。")
#             print(f"您共计完了{i}局，胜率为{rate*100}%,现有积分{golden_bean}分。")
#             if golden_bean<500:
#                 print("非常遗憾，由于您的积分小于500，游戏结束！")
#                 break
#             else:
#                 try_exit = input("若积分达到1600将有惊喜茶颜悦色大礼包，can you try?如需推出请输入exit并按enter键,直接按enter键则继续，您的选择是：")
#                 if try_exit == 'exit':
#                     print(f"游戏已结束，超超期待与{username}您的下一次相遇！")
#                     break
#                 else:
#                     print("游戏继续！惊喜大奖等你来领取！！！")
#     else:
#         print(f"恭喜玩家{username}您的积分已达1600，打通此关，获得超超赠送的茶颜悦色一杯，祝贺你！")
#         break







